#ifndef _OLED_H_
#define _OLED_H_

#include "main.h"
#include "spi.h"

#define OLED_USE_SPI
#define OLED_FULL 0
#define OLED_HALF 1

#define CMD0_DATA1          PBout(0)
#define OLED_CS             PBout(1)

/* 软件模拟 SPI */
#ifndef OLED_USE_SPI

#define OLED_MOSI           PAout(7)
#define OLED_CLK            PAout(5)

void oled_byte_write(uint8_t cmd);
void oled_write(uint8_t *cmd, uint8_t n);

/* 使用SPI1 */
#else

#define oled_write          spi1_write
#define oled_byte_write     spi1_byte_write

#endif // !USE_USE_SPI

/* 初始化和设置显存地址 */
void oled_init(void);
void oled_set_addr(uint8_t page, uint8_t column);
void oled_clear(void);
/* 像素级显示 */
void oled_display_128x64(uint8_t *dp);
void oled_display_16x16(uint16_t page, uint16_t column, uint8_t *dp);
void oled_display_24x24(uint16_t page, uint16_t column, uint8_t *dp);
void oled_display_8x16(uint16_t page, uint8_t column, uint8_t *dp);
void oled_display_5x7(uint16_t page, uint8_t column, uint8_t *dp);
/* 字符串显示 */
void oled_print_h16_string(uint8_t y, uint8_t x, uint8_t *text);
void oled_print_h7_string(uint8_t y, uint8_t x, uint8_t *text);
void oled_print_uint16(uint8_t y, uint8_t x, uint16_t n, uint8_t fullOrHalf);
void oled_print_hex8(uint8_t y, uint8_t x, uint8_t n, uint8_t fullOrHalf);
void oled_print_hex16(uint8_t y, uint8_t x, uint16_t n, uint8_t fullOrHalf);
/* 无用函数 */
void oled_zk_test();
#endif
